<template>
    <div>
        <a-modal v-model:visible="modalVisible" title="数据同步" @ok="handleOk" width="800px">
            <div>
                <div class="fz-14 col-8A93A7 mb-16">请选择要同步数据的网盘</div>
                <div class="flex mb-16">
                    <div class="cloud-card" @click="changeCloud(0)"  :class="{ 'active-cloud-card': currentCloud == '0'}" >
                        <svg-icon name="icon_al " class="cloud-icon" />
                    </div>
                    <div class="cloud-card" @click="changeCloud(1)" :class="{ 'active-cloud-card': currentCloud == '1'}" >
                        <svg-icon name="icon_tx " class="cloud-icon" />
                    </div>
                    <div class="cloud-card" @click="changeCloud(2)" :class="{ 'active-cloud-card': currentCloud == '2'}" >
                        <svg-icon name="icon_hw" class="cloud-icon" />
                    </div>
                    <div class="cloud-card" @click="changeCloud(3)" :class="{ 'active-cloud-card': currentCloud == '3'}" >
                        <svg-icon name="icon_hw " class="cloud-icon" />
                    </div>
                </div>
            </div>
            <div>
                <div class="fz-14 col-8A93A7 mb-16">跨实例同步数据</div>
                <div class="flex">
                    <div class="cloud-card" @click="changeCloud(4)" :class="{ 'active-cloud-card': currentCloud == '4'}">
                        <svg-icon name="icon_tb " class="cloud-icon" />
                    </div>
                </div>
            </div>
        </a-modal>

        <!-- 数据同步 -->
        <DataSync v-model="dataSyncVisible" v-if="dataSyncVisible" />
        <!-- 跨实例拷贝数据 -->
        <CopyData v-model="copyDataVisible" v-if="copyDataVisible" />
    </div>
</template>

<script setup>
import { defineProps, defineEmits, computed, ref } from 'vue';
import DataSync from './dataSync.vue'
import CopyData from './copyData.vue'

const props = defineProps({
    modelValue: {
        type: Boolean,
    },
});

const emit = defineEmits(['update:modelValue']);
const modalVisible = computed({
    get: () => props.modelValue,
    set: v => emit('update:modelValue', v),
});
// 确定按钮的回调

const dataSyncVisible = ref(false)
const copyDataVisible = ref(false)
const handleOk = () => {
    if (currentCloud.value == '4') {
        copyDataVisible.value = true
    } else {
        dataSyncVisible.value = true
    }

};

// 切换同步方式
const currentCloud = ref('0')
const changeCloud = (key, name) => {
    currentCloud.value = key
}

</script>

<style lang="less" scoped>
.cloud-card {
    padding: 20px 16px;
    border-radius: 4px;
    background: #F2F8FF;
    margin-right: 16px;
    border: 1px solid #F2F8FF;

    .cloud-icon {
        width: 120px;
        height: 30px;
    }
}
.active-cloud-card {
    border: 1px solid #07F;
}
</style>

